package com.ruoyi.damage.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.damage.domain.AlgsEquipmentDamage;
import com.ruoyi.damage.service.IAlgsEquipmentDamageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 器材损坏记录Controller
 * 
 * @author ruoyi
 * @date 2023-03-20
 */
@RestController
@RequestMapping("/damage")
public class AlgsEquipmentDamageController extends BaseController
{
    @Autowired
    private IAlgsEquipmentDamageService algsEquipmentDamageService;

    /**
     * 查询器材损坏记录列表
     */
//    @RequiresPermissions("damage:damage:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsEquipmentDamage algsEquipmentDamage)
    {
        startPage();
        List<AlgsEquipmentDamage> list = algsEquipmentDamageService.selectAlgsEquipmentDamageList(algsEquipmentDamage);
        return getDataTable(list);
    }

    /**
     * 导出器材损坏记录列表
     */
//    @RequiresPermissions("damage:damage:export")
//    @Log(title = "器材损坏记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsEquipmentDamage algsEquipmentDamage)
    {
        List<AlgsEquipmentDamage> list = algsEquipmentDamageService.selectAlgsEquipmentDamageList(algsEquipmentDamage);
        ExcelUtil<AlgsEquipmentDamage> util = new ExcelUtil<AlgsEquipmentDamage>(AlgsEquipmentDamage.class);
        util.exportExcel(response, list, "器材损坏记录数据");
    }

    /**
     * 获取器材损坏记录详细信息
     */
//    @RequiresPermissions("damage:damage:query")
    @GetMapping(value = "/{equipmentDamageId}")
    public AjaxResult getInfo(@PathVariable("equipmentDamageId") Long equipmentDamageId)
    {
        return success(algsEquipmentDamageService.selectAlgsEquipmentDamageByEquipmentDamageId(equipmentDamageId));
    }

    /**
     * 新增器材损坏记录
     */
//    @RequiresPermissions("damage:damage:add")
//    @Log(title = "器材损坏记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsEquipmentDamage algsEquipmentDamage) throws Exception {
        return toAjax(algsEquipmentDamageService.insertAlgsEquipmentDamage(algsEquipmentDamage));
    }

    /**
     * 修改器材损坏记录
     */
//    @RequiresPermissions("damage:damage:edit")
//    @Log(title = "器材损坏记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsEquipmentDamage algsEquipmentDamage)
    {
        return toAjax(algsEquipmentDamageService.updateAlgsEquipmentDamage(algsEquipmentDamage));
    }

    /**
     * 删除器材损坏记录
     */
//    @RequiresPermissions("damage:damage:remove")
//    @Log(title = "器材损坏记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentDamageIds}")
    public AjaxResult remove(@PathVariable Long[] equipmentDamageIds)
    {
        return toAjax(algsEquipmentDamageService.deleteAlgsEquipmentDamageByEquipmentDamageIds(equipmentDamageIds));
    }
}
